﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using GrainManage.Server.Factory;
using GrainManage.Entities.Image;
using GrainManage.Server.Business;

namespace GrainManage.Server.Controllers
{
    public class ImageController : BaseController
    {
        private readonly ImageBusiness business = new ImageBusiness();

        public string Index()
        {
            return GetInfo(this, business);
        }

        public string Schema()
        {
            return GetSchema(this, business);
        }

        #region 数据库版本

        //************************************************POST************************************************

        [HttpPost]
        public ActionResult GetImages(InputGetImages input)
        {
            var result = business.GetImages(input);
            return Json(result);
        }

        [HttpPost]
        public ActionResult Insert(InputInsert input)
        {
            var result = business.Insert(input);
            return Json(result);
        }

        [HttpPost]
        public ActionResult Update(InputUpdate input)
        {
            var result = business.Update(input);
            return Json(result);
        }

        [HttpPost]
        public ActionResult Delete(InputDelete input)
        {
            var result = business.Delete(input);
            return Json(result);
        }

        //[HttpPost]
        //public string BatchInsert(InputBatchInsert input)
        //{
        //    var result = business.BatchInsert(input);
        //    return Json(result);
        //}

        //[HttpPost]
        //public string BatchUpdate(InputBatchUpdate input)
        //{
        //    var result = business.BatchUpdate(input);
        //    return Json(result);
        //}

        //[HttpPost]
        //public string BatchDelete(InputBatchDelete input)
        //{
        //    var result = business.BatchDelete(input);
        //    return Json(result);
        //}
        #endregion

        #region 文件系统版本

        //************************************************POST************************************************

        [HttpPost]
        public ActionResult Download(InputGetImageFile input)
        {
            var result = business.GetImageFile(input);
            return Json(result);
        }

        #endregion
    }
}
